import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SheetButtonAuthData, SheetFormAuthData, SheetButtonAuthForm } from "@/api/sheet/sheetAuth/types";


/**
 * 获取应用按钮列表
 */
export const getSheetButtonList = (roleId: string | number): AxiosPromise<SheetButtonAuthData> => {
  return request({
    url: '/system/sheetAuth/getSheetButtonList',
    method: 'get',
    params: {roleId: roleId}
  });
};

/**
 * 保存应用按钮授权
 * @param data
 */
export const saveSheetAuthData = (data: SheetButtonAuthForm[]): AxiosPromise<any> => {
  return request({
    url: '/system/sheetAuth/saveSheetAuth',
    method: 'post',
    data: data
  });
};

/**
 * 获取应用表单及按钮授权数据
 * @param data
 */
export const getSheetFormAuthData = (roleId: string | number): AxiosPromise<SheetFormAuthData> => {
  return request({
    url: '/system/sheetAuth/getSheetFormAuthData',
    method: 'get',
    params: {roleId: roleId}
  });
};

/**
 * 保存应用表单及按钮授权
 * @param data
 */
export const saveSheetFormAuthData = (data: SheetFormAuthData): AxiosPromise<any> => {
  return request({
    url: '/system/sheetAuth/saveSheetFormAuthData',
    method: 'post',
    data: data
  });
};


